import {createStore, applyMiddleware} from 'redux'; // 仓库，中间件
import ReduxThunk from 'redux-thunk'; // 异步请求
import {persistStore, persistReducer} from 'redux-persist'; // 持久化
import storage from 'redux-persist/lib/storage' // 持久化默认存储方式是localstorage
import RootReducer from './reducer'; // 所有的reducer集合，携带命名空间
import {composeWithDevTools} from "redux-devtools-extension"; // Chrome浏览器的数据调试工具

const StorageConf = {
    keyPrefix: 'plc',
    key: 'console',
    blacklist: ["_persist"], // 黑名单
    whitelist: ["auth", "setting"], // 白名单
    storage
}

const StorageReducer = persistReducer(StorageConf, RootReducer);
const middleware = applyMiddleware(ReduxThunk);
const store = createStore(StorageReducer, composeWithDevTools(middleware));
const StorageStore = persistStore(store);

export {store, StorageStore}
